<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html >
<head>
	<title>Calendar - Localization</title>
	<meta charset="utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<meta name="description" content="" />
	<meta name="keywords" content="" />
	<meta name="author" content="ComponentOne" />
	
	<link href="<%=path %>/include/wijmo/themes/rocket/jquery-wijmo.css" rel="stylesheet" type="text/css" />
	<link href="<%=path %>/include/wijmo/themes/wijmo/jquery.wijmo.wijcalendar.css" rel="stylesheet" type="text/css" />
	<script src="<%=path %>/include/wijmo/external/jquery-1.8.0.min.js" type="text/javascript"></script>
	<script src="<%=path %>/include/wijmo/external/jquery-ui-1.8.23.custom.min.js" type="text/javascript"></script>
	<script src="<%=path %>/include/wijmo/external/globalize.min.js" type="text/javascript"></script>
	<script src="<%=path %>/include/wijmo/external/cultures/globalize.cultures.js" type="text/javascript"></script>
	<script src="<%=path %>/include/wijmo/wijmo/jquery.wijmo.wijpopup.js" type="text/javascript"></script>
	<script src="<%=path %>/include/wijmo/wijmo/jquery.wijmo.wijcalendar.js" type="text/javascript"></script>
	<script type="text/javascript">

	function sortByName(map) {
		// converts a dictionary into a sorted dictionary based on obj.name
		var arr = [];
		$.each(map, function (name, value) {
			arr.push(value);
		});
		arr.sort(function (a, b) {
			return a.name < b.name ? -1 : 1;
		});
		return arr;
	}

	$(function () {
		$("#calendar1").wijcalendar();
		$("#calendar1").wijcalendar({ culture: "zh-CN" });
		
		var sortedCultures = sortByName(Globalize.cultures);
		var list = $(".cultures");

		$.each(sortedCultures, function (i, culture) {
			$("<option/>", {
				value: culture.name,
				text: culture.name + ": " + (culture.englishName || "Invariant")
			}).appendTo(list);
		});
		list.val("en");
		list.bind("change keyup", function () {
			culture = list.val();
			alert(culture);
			$("#calendar1").wijcalendar({ culture: culture });
		});
	});

</script>
</head>
<body class="demo-single">
<div class="container">
	<div class="header">
		<h2>
			Localization</h2>
	</div>
	<div class="main demo">
		<!-- Begin demo markup -->
		<div id="calendar1">
		</div>
		<!-- End demo markup -->
		<div class="demo-options">
			<!-- Begin options markup -->
			<div class="option-row">
				<label for="cultures">
					Culture</label>
				<select class="cultures">
				</select>
			</div>
			<!-- End options markup -->
		</div>
	</div>
	<div class="footer demo-description">
		<p>
		This sample illustrates how to set the localization of the wijcalendar using the culture option. 
		</p>
	</div>
</div>
</body>
</html>
